//
//  NearBaseViewController.m
//  CarLife
//
//  Created by yu on 2017/11/16.
//  Copyright © 2017年 jpas. All rights reserved.
//

#import "NearBaseViewController.h"

#import "SearchAnnotation.h"
#import "SearchAnnotationView.h"

@interface NearBaseViewController ()

//@property (nonatomic, strong) NSMutableArray *poiAnnotations;

@end

@implementation NearBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];

//    self.navigationItem.title = @"NearBaseViewController";
    [self setLeftImageNamed:@"back_gray" action:@selector(returnAction)];
    [self initMapView];
    [self setupButton];
    
    [self.mapView addAnnotations:self.annotations];
    [self.mapView showAnnotations:self.annotations edgePadding:UIEdgeInsetsMake(40, 40, 340, 40) animated:NO];
}

- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id<MAAnnotation>)annotation
{
    if ([annotation isKindOfClass:[SearchAnnotation class]] )
    {
        static NSString *pointReuseIndetifier = @"ParkingAnnotationView";
        SearchAnnotationView *annotationView = (SearchAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pointReuseIndetifier];
        
        if (annotationView == nil)
        {
            annotationView = [[SearchAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pointReuseIndetifier];
        }
        annotationView.canShowCallout = NO;
        annotationView.draggable = NO;
        annotationView.image = IMAGE_NAMED(@"near_position_nor");
        
        return annotationView;
    }
    return nil;
}


- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self setWhiteNavigationBar];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self setDefaultNavigationBar];
}

//- (NSMutableArray *)annotations {
//    if (_annotations == nil) {
//        _annotations = [NSMutableArray array];
//    }
//    return _annotations;
//}

- (void)returnAction
{
    [self.navigationController popViewControllerAnimated:NO];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
